package top.huhuiyu.springboot2.study.validate;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 胡辉煜
 * 通用校验分组
 */
public interface CommonValidate {
  // 所有添加和修改功能都要添加合理的校验功能
  String EMAIL = "^[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w\\-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w\\-]*[\\w])?$";
  Pattern EMAIL_PATTERN = Pattern.compile(EMAIL);
  String USERNAME = "^[a-zA-Z][a-zA-Z0-9_]{3,15}$";

  default boolean isEmail(String email) {
    Matcher matcher = EMAIL_PATTERN.matcher(email);
    return matcher.matches();
  }

  interface Add {
  }

  interface Update {
  }

}
